<script src="${rc.getContextPath()}/manage/js/dwzCustomJs/dwz.custom.advancedquery.js?v=${ver}" type="text/javascript"></script>
<#include "/common/pagerForm.html">
<form rel="pagerForm" method="post" action="" onsubmit="return navTabSearch(this)">
	<input type="hidden" id="advancedStatus" name="advancedStatus" value="${condition.advancedStatus!''}" />
    <div class="pageHeader">
        <div class="searchBar defect" >
            <ul class="searchContent">
            	<li>
            		<label><@label key="distributionNum.C,colon">配送需求编号：</@label></label> 
            		<input type="text" class="textInput" name="distributionNum" value="${condition.distributionNum!''}" />
            	</li>
            	<li>
            		<label><@label key='materialCode.C,colon'>物料编号：</@label></label> 
            		<input type="text" name="materialCode" value="${condition.materialCode!''}"/>
            	</li>
            	<li>
            		<label><@label key="requirementNum.C,colon">需求编号：</@label></label> 
            		<input type="text" class="textInput" name="requirementNum" value="${condition.requirementNum!''}" />
            	</li>
            </ul>	
            <ul class="searchContent">
            	<li>
            		<label><@label key='productionOrderNum.C,colon'>生产订单编号：</@label></label> 
            		<input type="text" class="textInput" name="productionOrderNum" value="${condition.productionOrderNum!''}"/>
            	</li>
            	<li>
            		<label><@label key='productionControlNum.C,colon'>生产管理号：</@label></label> 
            		<input type="text" class="textInput" name="productionControlNum" value="${condition.productionControlNum!''}" />
            	</li>
				<li>
					<label><@label key='status.C,colon'>状态：</@label></label> 					
					<select name="statusECode">
	                    <option value="" ><@label key='all.C'>所有</@label></option>
	                    <#if ecodes??>
	                        <#list ecodes as ecode>
	                            <option value="${ecode.eCode!''}" <#if condition.statusECode?? && condition.statusECode == ecode.eCode> selected</#if> >${ecode.eCodeText!''}</option>
	                        </#list>
	                    </#if>
	                </select>
				</li>
				<li class="query">
                    <div class="buttonActive">
                        <div class="buttonContent">
                            <button type="submit"><@label key="query.B">查询</@label></button>
                        </div>
                    </div>
                </li> 
                <li class="advancedQuery" >            
	                <a id="advancedQuery"href="javascript:void(0);"   onclick="openAdvanced(navTab.getCurrentPanel())">
	                    <@label key="advancedQuery.C">高级查询</@label>
	                </a>
	                <span  onclick="openAdvanced(navTab.getCurrentPanel());"></span>            
	            </li>  
            </ul>	            
        </div>
    </div>
	<div id="collapsablePanel" style="display:none;" class="pageHeader" >
	    <div class="searchBar">
	    	<ul class="searchContent">
                <li>
                	<label><@label key="workCenterCode.C,colon">工作中心编号:</@label></label> 
                	<input id="workCenterGrp.workCenterCode" name="workCenterCode" type="text" suggestFields="workCenterCode,workCenterText" 
                	postField="workCenterCode" suggestUrl="${rc.getContextPath()}/manage/workCenter/workCenterSuggest" 
                	lookupGroup="workCenterGrp" autocomplete="off" value="${condition.workCenterCode!''}" />
                </li>
				<li>
					<label style="width: 120px;"><@label key="workUnitCode.C,colon">作业单元编号</@label></label>
					<input  id="workUnitCode" name="workUnitCode" type="text" postField="workUnitCode" 
                    suggestFields="workUnitCode,workUnitText"  value="${condition.workUnitCode!''}" 
                    suggestUrl="${rc.getContextPath()}/manage/workUnit/workUnitSuggest" />
				</li>             
				<li>
            		<label><@label key="theLine.C,WarehouseCode.C,colon">线边仓库：</@label></label> 
            		<input type="text" class="textInput" name="warehouseCode" value="${condition.warehouseCode!''}" />
            	</li>
            	<li>
            		<label><@label key="theLine.C,storageLocation.C,colon">线边库位：</@label></label> 
            		<input type="text" class="textInput" name="locationCode" value="${condition.locationCode!''}" />
            	</li>
            </ul>	    	
	        <ul class="searchContent">
	        	<li>
	        		<label><@label key='createDateTime.C,colon'>创建日期从：</@label></label>
	            	<input type="text" class="date" readonly="readonly" size="17" max_Date="{maxCreateDateTime}"  name="minCreateDateTime" value="${condition.minCreateDateTime!''}"/>
	            	<a class="inputDateButton" href="javascript:;">选择</a>
	            </li>
	            <li>
	            	<label style="width: 120px;"><@label key="to.C,colon">至：</@label></label>
	            	<input type="text" class="date" readonly="readonly" size="17" min_Date="{minCreateDateTime}" name="maxCreateDateTime"  value="${condition.maxCreateDateTime!''}"/>
	            	<a class="inputDateButton" href="javascript:;">选择</a>
	            </li>
	            <li>
            		<label><@label key="createUser.C,colon">创建人：</@label></label> 
            		<input type="text" class="textInput" name="createUser" value="${condition.createUser!''}" />
            	</li>
            	<li>
            		<label><@label key="distributionMode.C,colon">配送形式：</@label></label> 
            		<input type="text" class="textInput" name="distributionMode" value="${condition.distributionMode!''}" />
            	</li>
	        </ul>
	        
	        <ul class="searchContent">
	        	<li>
	        		<label><@label key='closeDateTime.C,from.C,colon'>需求关闭时间从：</@label></label>
	            	<input type="text" class="date" readonly="readonly" size="17" max_Date="{closeEndDate}"  name="closeStartDate" value="${condition.closeStartDate!''}"/>
	            	<a class="inputDateButton" href="javascript:;">选择</a>
	            </li>
	            <li>
	            	<label style="width: 120px;"><@label key="to.C,colon">至：</@label></label>
	            	<input type="text" class="date" readonly="readonly" size="17" min_Date="{closeStartDate}" name="closeEndDate"  value="${condition.closeEndDate!''}"/>
	            	<a class="inputDateButton" href="javascript:;">选择</a>
	            </li>
	            <li>
            		<label><@label key="closeUser.C,colon">关闭人：</@label></label> 
            		<input type="text" class="textInput" name="closeUser" value="${condition.closeUser!''}" />
            	</li>
            	<li>
            		<label><@label key="distributionUser.C,colon">配送人员：</@label></label> 
            		<input type="text" class="textInput" name="distributionUser" value="${condition.distributionUser!''}" />
            	</li>
	        </ul>
	        <ul class="searchContent">
	        	<li>
                	<label><@label key="pullStrategyCode.C,colon">拉动策略编号：</@label></label> 
                	<input type="text" class="textInput" name="pullStrategyCode" value="${condition.pullStrategyCode!''}" />
                </li> 
                <li>
                	<label style="width: 120px;"><@label key="requirementTriggerMode.C,colon">需求触发策略：</@label></label> 
                	<input type="text" class="textInput" name="requirementTriggerModeCode" value="${condition.requirementTriggerModeCode!''}" />
                </li>               
				<li>
                	<label><@label key="distributionTriggerModeCode.C,colon">配送触发策略：</@label></label> 
                	<input type="text" class="textInput" name="distributionTriggerModeCode" value="${condition.distributionTriggerModeCode!''}" />
                </li>             
            </ul>
	    </div>.
	</div> 
</form>
<div class="pageContent">
    <div class="panelBar">
        <ul class="toolBar">
            <@buttonRight menuCode="CONFIRMDISTRIBUTION" labelKey="confirmServed.C" defalutName="确认送达">
            <li>
            	<a class="add" target="dialog" mask="true" width="350" height="150" preevent="distributionJs._checkEditButtonEnable"
            	href="${rc.getContextPath()}/manage/distribution/confirmDistribution?distributionNum={distribution_code}&navTabId=${navTabId!''}" 
            	rel="adddefect" title="<@label key='confirmServed.C'>确认送达</@label>">
            		<span><@label key="confirmServed.C">确认送达</@label></span>
            	</a>
            </li>
            </@buttonRight>
            <@buttonRight menuCode="CANCELDISTRIBUTION" labelKey="cancelDistribution.B" defalutName="取消配送需求">
            <li>
            	<a class="delete" target="ajaxTodo" title="<@label key='cancelDistribution.D'>确认取消配送需求？</@label>" preevent="distributionJs._checkEditButtonEnable"
            	href="${rc.getContextPath()}/manage/distribution/cancelDistribution?distributionNum={distribution_code}&navTabId=${navTabId!''}"  >
            		<span><@label key="cancelDistribution.B">取消配送需求</@label></span>
            	</a>
            </li>
            </@buttonRight>
            <@buttonRight menuCode="VIEWREQUIREMENTTRIGGERMODE" labelKey="view.B" defalutName="详情">
            <li>
            	<a class="icon" target="dialog" mask="true" width="700" height="600" 
            	href="${rc.getContextPath()}/manage/distribution/viewDistribution?distributionNum={distribution_code}&navTabId=${navTabId!''}" 
            	rel="viewdefect" title="<@label key='viewDistribution.B'>配送需求单详情</@label>">
            		<span><@label key="view.B">详情</@label></span>
            	</a>
            </li>
            </@buttonRight>
        </ul>
    </div>
    <table class="table" width="160%" layoutH="160" style="overflow:scroll;">
        <thead>
            <tr>
                <th width="30px"><@label key="serialNumber.C">序号</@label></th>
                <th width="110"><@label key="distributionNum.C">配送需求编号</@label></th>
                <th width="80"><@label key='materialCode.C'>物料编号</@label></th>
                <th width="100"><@label key='materialText.C'>物料描述</@label></th>                
                <th width="100"><@label key="materialspec.C">物料规格</@label></th>
                <th width="80"><@label key="requiredQuantity.C">需配数量</@label></th>
                <th width="80"><@label key="actualQuantity.C">实发数量</@label></th> 
                <th width="180"><@label key="createDateTime.C">创建时间</@label></th>              
                <th width="180"><@label key="closeDateTime.C">需求关闭时间</@label></th>
                <th width="100"><@label key="requirementTriggerMode.C">需求触发策略</@label></th>
                <th width="50"><@label key="status.C">状态</@label></th>
                <th width="80"><@label key="workCenterCode.C">工作中心编号</@label></th>
                <th width="80"><@label key="workUnitCode.C">作业单元编号</@label></th>
                <th width="90"><@label key="theLine.C,WarehouseCode.C">线边仓库</@label></th>
                <th width="80"><@label key="theLine.C,storageLocation.C">线边库位</@label></th>                
                <th width="80"><@label key="pullStrategy.C">拉动策略</@label></th>
                <th width="100"><@label key="distributionTriggerMode.C">配送需求触发策略</@label></th>
                <th width="80"><@label key="distributionMode.C">配送形式</@label></th>                
                <th width="80"><@label key="distributionUser.C">配送人员</@label></th>                
                <th width="80"><@label key="createUser.C">创建人</@label></th>                
                <th width="80"><@label key="modifyUser.C">修改人</@label></th>
                <th width="180"><@label key="modifyDateTime.C">修改时间</@label></th>
                <th width="80"><@label key="closeUser.C">关闭人</@label></th>
                <th width="180"><@label key="closeDate.C">关闭时间</@label></th>
            </tr>
        </thead>
        <tbody>
            <#if page??><#if (page.data?size>0)> <#list page.data as distribution>
            <tr target="distribution_code" rel="${distribution.distributionNum!''}">
                <td>${page.startRow + distribution_index}</td>
                <td>${distribution.distributionNum!''}</td>
                <td>${distribution.materialCode!''}</td>
                <td>${distribution.materialText!''}</td>
                <td>${distribution.materialSpec!''}</td>
                <td>${distribution.distributionQuantity!'0'}</td>  
                <td>${distribution.actualQuantity!'0'}</td>  
                <td>${distribution.createDateTime?string("yyyy-MM-dd HH:mm:ss")}</td>
                <#if distribution.closeDateTime??>
                	<td>${distribution.closeDateTime?string("yyyy-MM-dd HH:mm:ss")}</td>
                <#else>
                	<td></td>
                </#if>
                <td>${distribution.requirementTriggerModeCode!''}-${distribution.requirementTriggerModeText!''}</td>                  
                <td><#if ecodes??>
                    <#list ecodes as ecode>
                        <#if distribution.statusECode == ecode.eCode>${ecode.eCodeText!''}<#break></#if>
                    </#list>
                </#if>
                </td>   
                <td>${distribution.workCenterCode!''}</td>   
                <td>${distribution.workUnitCode!''}</td>   
                <td>${distribution.warehouseCode!''}</td>   
                <td>${distribution.locationCode!''}</td>   
                <td>${distribution.pullStrategyText!''}</td>   
                <td>${distribution.distributionTriggerModeText!''}</td>   
                <td>${distribution.distributionModeText!''}</td>   
                <td>${distribution.distributionUser!''}</td>
                <td>${distribution.createUser!''}</td>
                <td>${distribution.modifyUser!''}</td>
                <td>${distribution.modifyDateTime?string("yyyy-MM-dd HH:mm:ss")}</td>
                <td>${distribution.closeUser!''}</td>  
                <#if distribution.closeDateTime??>
                	<td>${distribution.closeDateTime?string("yyyy-MM-dd HH:mm:ss")}</td>
                <#else>
                	<td></td>
                </#if>
            </tr>
            </#list> <#else>
                <tr >
                <td colspan="7"  class="noData">======<@label key="noListData.C">列表无数据</@label>=====
                </td>
            </tr>
            </#if> <#else>
            <tr >
                <td colspan="7"  class="noData">======<@label key="noListData.C">列表无数据</@label>=====
                </td>
            </tr>
            </#if>
        </tbody>
    </table>
    <#include "/common/panelBar.html">
</div>
<script type="text/javascript">
    $(function() {
        initAdvancedQuery(navTab.getCurrentPanel());        
    });
    var distributionJs = {
            editEnable : true,
            _checkEditButtonEnable : function() {
                var id = $("#distribution_code",navTab.getCurrentPanel()).val();
                distributionJs.editEnable = true;
                if(id && id!=""){
                    $.ajax({
                        async : false,
                        dataType : "json",
                        url:hostUrl +"/distribution/checkedButtonEnable",
                        data:{'distributionNum':id},
                        success:function(data){
                            if(data.statusCode == DWZ.statusCode.error){
                                distributionJs.editEnable = false;
                                alertMsg.error(data.message);
                            }
                        }
                    });
                }
                return distributionJs.editEnable;
            }
    }
</script>